<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <meta http-equiv="Pragma" content="no-cache"/>
    <meta http-equiv="no-cache"/>
    <meta http-equiv="Expires" content="-1"/>
    <meta http-equiv="Cache-Control" content="no-cache"/>
    <title>查看产品</title>

    <script type="text/javascript">
      var rejectProductWin;
      Ext.onReady(function(){
              Ext.QuickTips.init();
              
              var productId = <%= params[:id] %>;
              var random = Math.ceil(Math.random()*(1000-1)+1);
              var productViewForm=new Ext.form.FormPanel({
                    width:600,
                    //labelAlign: 'top',
                    buttonAlign:'center',
                    autoHeight:true,
                    fileUpload: true,
                    bodyStyle: 'padding:5px',
                    labelWidth:100,
                    waitMsgTarget: true,
                    frame: true,
                    reader:new Ext.data.JsonReader({
                       },[
                       {name:'id'},
                       {name:'name'},
                       {name:'vendor_name',mapping:'vendor.company_name'},
                       {name:'model'},
                       {name:'brand'},
                       {name:'manufacturer'},
                       {name:'specification'},
                       {name:'unit_price'},
                       {name:'technology_data'}
                      ]
                    ),
                    items:[{
                          layout:'column',
                          items:[{
                              columnWidth:.5,
                              layout:'form',
                              labelAlign: 'left',
                              items:[{
                                  xtype:'textfield',
                                  fieldLabel: '供应商',
                                  name: 'vendor_name',
                                  allowBlank:false,
                                  readOnly:true,
                                  anchor:'90%'
                              },{
                                  xtype:'textfield',
                                  fieldLabel: '生产单位',
                                  name:'manufacturer',
                                  allowBlank:false,
                                  readOnly:true,
                                  anchor:'90%'
                              },{
                                  xtype:'textfield',
                                  fieldLabel: '型号',
                                  name: 'model',
                                  allowBlank:false,
                                  readOnly:true,
                                  anchor:'90%'
                              },{
                                  xtype:'textfield',
                                  fieldLabel: '产品品牌',
                                  name: 'brand',
                                  readOnly:true,
                                  allowBlank:false,
                                  anchor:'90%'
                              }]
                          },{
                              columnWidth:.5,
                              layout:'form',
                              labelAlign: 'left',
                              items:[{
                                  xtype:'textfield',
                                  fieldLabel: '产品名称',
                                  name: 'name',
                                  readOnly:true,
                                  allowBlank:false,
                                  anchor:'90%'
                              },{
                                  xtype:'textfield',
                                  fieldLabel: '规格',
                                  name: 'specification',
                                  allowBlank:false,
                                  readOnly:true,
                                  anchor:'90%'
                              },{
                                  fieldLabel: '单价（元）',
                                  xtype:'numberfield',
                                  name: 'unit_price',
                                  allowBlank:false,
                                  readOnly:true,
                                  anchor:'90%'
                              }]
                          }]
                     },{
                          layout:'column',
                          items:[{
                              columnWidth:1,
                              layout:'form',
                              labelAlign: 'top',
                              items:[
                              {
                                  html:'<br><img align="left" src="/images/height.bmp"><center><img src="/product/getPhoto?id='+productId+'&random='+random+'" style=max-width:160px; max-height:120px alt="产品图片"/></center>'
                              },{
                                  xtype:'textarea',
                                  fieldLabel: '主要技术指标',
                                  name: 'technology_data',
                                  height:50,
                                  readOnly:true,
                                  anchor: '95%'
                              }]
                          }]
                     }],
                     buttons:[{
                        text:'关闭',
                        handler:function(){
                            productViewWin.destroy();
                        }
                    }]
                });
          productViewForm.form.load({
               url: '/product/edit?id=' + productId,
               success: function(form, action){
               },
               failure: function(form, action){
                  Ext.MessageBox.alert('提示信息', '信息加载失败');
               }
          });
          productViewForm.render('product_view_form');
      })
    </script>
  </head>
  <body>
     <div id="product_view_form"></div>
  </body>
</html>
